/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hibernate;

import com.partaljevic.gambling.beans.Match;
import com.partaljevic.gambling.beans.Pair;
import com.partaljevic.tapestry.gambling.service.PairsOfTickets;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;

/**
 *
 * @author Nemanja
 */
public class PairsOfTicketsHibrenate implements PairsOfTickets{

    private final Session session;

    public PairsOfTicketsHibrenate(Session session) {
        this.session = session;
    }

    @Override
    public void save(Pair pair) {
        session.save(pair);
    }

    @Override
    public void update(Pair pair) {
        session.saveOrUpdate(pair);
    }

    @Override
    public List<Pair> retreive() {
        Criteria criteria = session.createCriteria(Pair.class);
        return criteria.list();
    }

    @Override
    public Pair retreive(Serializable id) {
        return (Pair) session.get(Pair.class, id);
    }


}
